from django.db import models


class ForwardConfig(models.Model):
    namespace = models.CharField(max_length=36, verbose_name='命名空间')
    service_name = models.CharField(max_length=36, verbose_name='服务名称')
    hosts = models.TextField(verbose_name='微服务主机')
    config_time = models.DateTimeField(auto_now_add=True, verbose_name='配置时间')
    reload_time = models.DateTimeField(auto_now=True, verbose_name='重载时间')
    checksum = models.CharField(max_length=36, verbose_name='校验码')


class CurrentLimiter(models.Model):
    config = models.ForeignKey(ForwardConfig, verbose_name='重定向配置', related_name='limiter', on_delete=models.CASCADE)
    limit = models.IntegerField(default=1, verbose_name='限流(秒/次)')
